home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
extenbat.arc
/
BATDEMO.BAT
< prev
next >
Wrap
DOS Batch File
|
1983-07-01
|
10KB
|
257 lines
bat * Begin Batch Language Demo * (C)opyright by Seaware Corp. 1982, 1983
bat * (C)opyright by Frank Canova 1982, 1983
bat * Send contributions to: Seaware Corp.
bat * P.O. Box 1656
bat * Delray Beach, FL 33444
bat *---- FEATURES OF THE LANGUAGE USED WITHIN THIS DEMO ARE: ----------------
bat * Standary DOS commands can be intermixed freely with BAT commands.
bat * Like basic, putting things at top is quicker for goto's / loops to find.
bat * Up to 15 chars are allowed for labels, contents of vars, and literals
bat * 10 variables are provided to be passed to/from DOS. They're %0 to %9.
bat * 15 variables are provided for user use only. They're %A to %O.
bat * The variable %R is a return code that any routine can set at [0:04FE]
bat * Note that 'BEGTYPE' & 'BEGSTACK' do not do variable substitution.
bat * BEGTYPE command can have screen attributes via a '\hex' format.
bat * BEGSTACK command can have timing attributes via a '\hex' format.
bat * Spaces are needed to delimit operators.
bat * Non-spaces will concatenate variables and literals.
bat * STATEOF sets return code based on state of files existance.
bat cls begtype
╔════════════════════════════════════════════════════════════════════════╗
║ (C)opyright by Seaware Corp. 1982, 1983 ║
║ (C)opyright by Frank Canova 1982, 1983 ║
║ ║
║ This is User Supported Software :: ║
║ ║
║ You are encouraged to copy and share this program with other users, ║
║ on the conditions that the program is not distributed in modified ║
║ form, that no fee or consideration is charged, and that this notice ║
║ is not bypassed or removed. ║
║ ║
║ PRIVATE USERS, If you are using this program and finding it of value, ║
║ your contribution ($30 suggested) will be appreciated. ║
║ ║
║ The $30 license fee (per system) is required for COMMERCIAL USERS if ║
║ used in a place of business or put into another product. ║
║ ║
║ Seaware Corp. ║
║ P.O. Box 1656 ║
║ Delray Beach, FL 33444 ║
║ ║
╚════════════════════════════════════════════════════════════════════════╝
End
bat type What is your first name? ==> ;
bat read %8
bat %7 = 27
bat %L =
bat goto -top
bat * number guessing demo *
bat -i.can.count %6 = 5
bat cls type i am thinking of a two digit number, can you guess it?
bat -c.loop read %5
bat if %5 = %7 skip 7
bat %6 = %6 - 1
bat if %6 <> 0 skip 2
bat type boo hisss! the number was %7!
bat skip 4
bat if %5 > %7 type try a little lower. you only get %6 more tries.
bat if %5 < %7 type try a higher number. you get %6 more tries.
bat goto -c.loop
bat type great! i was afraid you weren't going to get it!
bat begtype
A BAT program can create loops and count events. With this you can
sequence through file numbers, or create loops to do retrys in case of
errors. In addition, BAT programs can do simple arithmetic and string
manipulation.
(press any key to continue)
end
bat inkey
bat -top cls type ======== %8's extended batch sampler menu ===========
bat begtype
\0FC\07 - I can Count
\0fD\07 - Directory of available programs
\0fF\07 - Testing for files
\0fK\07 - Keyboard stack (the invisible fingers)
\0fS\07 - Display Screen and String operations
\0fX\07 - Exit
Select an option.
end
bat -entry read %9
bat %7 = %7 + 3
bat * Skiping is quicker than goto's, but only goes forward.
bat if %9 <> d goto -not.d
bat type enter file.spec for files you would like to see, or press ENTER for all.
bat read %1
bat if .%1 = . %1 = *.*
bat -dirques type Would you like a (S)tandard or (W)ide directory?
bat inkey %2 | %m = %2 # | if %m = 1 type %2
bat * Notice you can chain togeather if's, like . . .
bat if %2 <> s if %2 <> w goto -dirques
bat %3 =
bat if %2 = w %3 = /w
bat cls
dir %1 %3 (notice that two parms are passed to dos here. %%1 and %%3)
bat * Returning to Extended Batch demo *
bat begtype
This directory was created by using a DOS command within this batch file. Any
DOS command can be mixed freely within lines of the BAT program. By passing
parameters to/from DOS, you can have complete control of how a program
operates. User programs may also set a return code in order to control the
execution of the BAT batch file program.
Press any key to continue. . .
end
bat inkey
bat goto -top
bat -not.d if %9 <> x skip 3
bat type so long %8....
bat type p.s. for quickie help, just enter 'bat' from dos.
bat exit
bat if %9 = c goto -i.can.count
bat if %9 <> f goto -not.f
bat type enter a file name for me to search for.
bat read %9
bat type scanning for file: %9 . . .
bat stateof %9 * this will set the return code up (%R)
bat if %r <> 0 skip 2
bat type the file does exist - exactly as typed.
bat skip 7
bat if %r <> 1 skip 2
bat type the file does not exist on any drive.
bat skip 5
bat if %r <> 9 skip 2
bat type the file name given is invalid.
bat skip 2
bat type the file does exist - but was found on the %r drive.
bat type to properly find this file, the complete filename would be %9
bat begtype
File searching is done by a command called STATEOF.
If the file was there, we could direct a program to use it, even if it wasn't
on the specific diskette drive that the operator was expecting.
If the file was not there, we could have printed out an error message to the
operator, or we could have run an alternate program in order to create the
missing file.
Press any key to continue . . .
end
bat inkey
bat goto -top
bat -not.f if %9 <> k goto -not.k
bat cls begtype
╔═════════════════════════════════════════════════════════════════════════════╗
║ ║
║ The keyboard stack can answer questions to programs automatically. ║
║ For example, this DOS command can be responded to from the stack. ║
║ ║
╚═════════════════════════════════════════════════════════════════════════════╝
end
bat begstack
This text is actually being typed for you from the keyboard stack.
All keys, including control keys and function keys can come from this stack.
Keystrokes can \ff\10even \ff\10have \ff\10delayed \ff\10typing.
\1a
end
rem ... Below is the DOS command that will read the keyboard stack.
copy con: nul:
bat *returning from DOS command*
bat begtype
(press any key to continue)
end
bat inkey
bat goto -top
bat -not.k if %9 <> s goto -not.s
bat cls begtype
╔═════════════════════════════════════════════════════════════════════════════╗
║ ║
║ All sorts of screen attributes can be printed on the screen. ║
║ ║
║ On monochrome display you see: On color display you see: ║
╚═════════════════════════════════════════════════════════════════════════════╝
\04Normal Red on Black \07
\0fHigh Intensity High Intensity\07
\21Underlined Blue on Green \07
\85Flashing Normal Flashing Magenta on Black\07
And \0fmany\07 other combinations!
\1b[33;44m Users of DOS 2.0 ANSI.SYS can also control the display. \1b[0m
(press any key to continue)
end
bat inkey
bat cls
bat -rd.name1 if .%8 <> . skip 3
bat type i didn't catch your first name, what was it?
bat read %8
bat goto -rd.name1
bat type i know that your first name is %8
bat -rd.name2 if .%L <> . skip 3
bat type i didn't catch your last name, what was it?
bat read %L
bat goto -rd.name2
bat type
bat type i am using your name as two strings to work with.
bat type
bat type comparisons can be made . . .
bat if %8 = %L type the strings are equal.
bat if %8 <> %L type the strings are not equal.
bat * notice a '.' will make sure that null entries can be found
bat type
bat type Strings contents can be manipulated . . .
bat type CONCATENATION.. They can be combined to form %8%L
bat type CONCATENATION.. or to form %L%8.
bat %I = %8 $ 1 1
bat %I = %I.%L $ 1 3
bat %H = %8 #
bat type SUBSTRINGS..... Your initials would be %I.
bat type LENGTHS........ Your first name has %H letters.
bat begtype
Strings will be truncated at 15 characters and may be passed back
and forth from DOS. There are 10 variables for strings which may
operate with DOS, and 15 which can be used even between
executing BAT programs. There are another 5 variables which
have predefined (fixed) contents to give status, etc. String operations
and comparisons can be done as well.
(Press any key to continue)
end
bat inkey
bat goto -top
bat -not.s BEGTYPE
You did not select a valid option.
Press \0FC, D, F, S or X\07.
END
bat goto -entry